package com.lyn.pluginbazaar.config;

import com.lyn.pluginbazaar.dao.user.User;
import com.lyn.pluginbazaar.dao.user.UserDao;
import com.lyn.pluginbazaar.utils.DesUtil;
import com.lyn.pluginbazaar.utils.SpringUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UserConfig {


    @Bean
    public static void initUser() {
        UserDao userDao = SpringUtils.getBean(UserDao.class);

        long count = userDao.count();
        if (count < 1) {
            User user = new User();
            user.setUserName("admin");
            user.setPassword(DesUtil.getInstance().encrypt("123456"));
            user.setTime(System.currentTimeMillis());
            userDao.save(user);
        }
    }
}
